Skip to content

feat(providers): add Baseten Model APIs preset - #653

Open
olddonkey wants to merge 1 commit into
lidge-jun:devfrom
olddonkey:codex/572-baseten-model-apis
Open

feat(providers): add Baseten Model APIs preset#653
olddonkey wants to merge 1 commit into
lidge-jun:devfrom
olddonkey:codex/572-baseten-model-apis

Conversation

@olddonkey

@olddonkey olddonkey commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Add baseten as a first-class API-key preset for Baseten's shared Model APIs at https://inference.baseten.co/v1.
  • Use bounded authenticated /v1/models discovery (1 MiB response, 256 raw rows) while preserving an existing same-named custom provider's destination and adapter.
  • Preserve provider-native model IDs, including embedded slashes, and expose only capability metadata documented for specific live slugs.
  • Add fixture-only provider tests and synchronize the provider catalog documentation across all maintained locales.

This PR is the Baseten provider consumer under umbrella issue #572. It relates to #572 but must not close it; additional provider batches remain.

Scope

  • Covers Baseten's shared public Model APIs using the OpenAI-compatible Bearer-key flow.
  • Excludes dedicated Truss model and chain predict endpoints, which use different hosts and request schemas.
  • Does not add Baseten OAuth; no supported OAuth flow is documented for this endpoint.
  • Documents personal keys for local use and appropriately scoped team keys for shared or production use.

Canonical preset evidence

Primary sources were checked on 2026-07-31.

Requirement Evidence
OpenAI-compatible chat endpoint Baseten's official Model APIs guide documents the OpenAI-compatible base URL https://inference.baseten.co/v1 and the exact POST https://inference.baseten.co/v1/chat/completions endpoint with Authorization: Bearer $BASETEN_API_KEY. The Inference API overview independently identifies Model APIs as Baseten-managed shared infrastructure and lists the same chat endpoint.
Authenticated model catalog The same official Model APIs guide, "List available models" documents GET https://inference.baseten.co/v1/models with Authorization: Bearer $BASETEN_API_KEY.
Terms and operating entity Baseten's Terms and Conditions (last updated 2026-01-30) state that the agreement is with Baseten Labs, Inc.; the incorporated DPA identifies it as a U.S. corporation with its principal business address in San Francisco.
Resale/routing authorization Not applicable. This preset connects directly to Baseten's own first-party inference host and Baseten-managed Model APIs, rather than an independent reseller or aggregator.
Maintenance owner @olddonkey owns ongoing maintenance of the Baseten preset. Endpoint, authentication, catalog-shape, or terms breakage will be reported in an opencodex issue tagging the owner; the preset will then be updated or deprecated rather than silently left stale.
Contributor affiliation I have no employment, financial, or other affiliation with Baseten and received no compensation for this contribution.

Security

This is a credential-destination change. The preset uses redirect denial and preserveCustomDestination, does not persist registry-only discovery trust policy, and introduces no credential logging. An explicit maintainer security review/sign-off is requested before merge.

Verification

  • bun run typecheck
  • Focused Baseten, discovery-contract, registry-parity, connection-probe, and catalog tests: 186 passed, 0 failed
  • bun run test: 6,494 passed, 4 skipped, 0 failed across 471 test files
  • bun run privacy:scan
  • Docs Astro build: 146 pages

Checklist

  • Scope stays focused and avoids unrelated cleanup.
  • Documentation is synchronized across maintained locales.
  • Canonical preset evidence, maintenance ownership, verification date, and affiliation are disclosed above.
  • Explicit maintainer security sign-off (requested).

@coderabbitai

coderabbitai Bot commented Jul 29, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

This PR adds bounded, registry-driven provider model discovery, transport-aware registry matching, and the Baseten Model APIs preset. It integrates discovery into catalog loading, API-key validation, routing, management probes, tests, and multilingual documentation.

Changes

Provider discovery and registry integration

Layer / File(s) Summary
Registry contracts and Baseten preset
src/providers/registry.ts, src/codex/catalog/parsing.ts
Adds typed discovery policies, transport matching, collision preservation, normalized capabilities, and the Baseten registry configuration.
Bounded discovery parsing and catalog enrichment
src/providers/model-discovery.ts, src/codex/catalog/provider-fetch.ts
Adds bounded JSON handling, URL resolution, predicate filtering, row validation, deduplication, and richer provider metadata normalization.
Discovery-aware requests and transport-gated behavior
src/oauth/..., src/providers/derive.ts, src/router.ts, src/server/...
Uses resolved discovery URLs for model requests and validation, rejects redirects, and applies registry data only when configured transports match.
Baseten and discovery contract verification
tests/baseten-provider.test.ts, tests/provider-model-discovery-contract.test.ts, tests/provider-connection-test.test.ts, tests/fixtures/*, tests/umans-provider.test.ts, tests/codex-catalog.test.ts, tests/provider-registry-parity.test.ts
Adds Baseten routing and metadata tests, bounded discovery edge-case coverage, fixtures, connectivity-probe assertions, and updated validation callers.
Runtime and localized documentation
structure/01_runtime.md, docs-site/src/content/docs/**
Documents live discovery limits, fallback behavior, collision preservation, updated preset counts, and Baseten Model APIs across supported locales.

Estimated code review effort: 5 (Critical) | ~120 minutes

Possibly related issues

Possibly related PRs

Suggested reviewers: wibias, ingwannu, lidge-jun

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 22.45% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely identifies the main change: adding the Baseten Model APIs provider preset.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot added the enhancement New feature or request label Jul 29, 2026
@olddonkey
olddonkey marked this pull request as ready for review July 29, 2026 00:48

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
docs-site/src/content/docs/ru/reference/configuration.md (1)

166-166: 📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win

Russian docs missing the new collision-preservation baseUrl behavior that zh-cn received.

docs-site/src/content/docs/zh-cn/reference/configuration.md was updated in this same PR (lines 138 and 184-190) to document that newly-added, collision-protected fixed API-key presets (like Baseten) preserve an existing same-named custom provider's baseUrl/adapter instead of redirecting it to the new registry host. This Russian page's baseUrl row (line 166) and its "fixed provider endpoints" section (unchanged lines 209-278) were not updated to match, leaving ru readers with an incomplete/outdated description of baseUrl override precedence — directly contradicting the path-instruction requirement that "translated locale pages ... are not left contradicting the English source."

As per path instructions, docs-site/** guidance requires that "translated locale pages (ja, ko, ru, zh-cn) are not left contradicting the English source."

📝 Suggested ru addition (adapt zh-cn wording)
-| `baseUrl` | `string` | Базовый URL вышестоящего API. |
+| `baseUrl` | `string` | Базовый URL вышестоящего API. Большинство встроенных provider с фиксированными конечными точками игнорируют несовпадающий адрес; новые пресеты с ключевой аутентификацией, включающие защиту от коллизий, сохраняют цель ранее существовавшего custom provider с тем же именем. См. [Фиксированные конечные точки провайдера](`#фиксированные-конечные-точки-провайдера`). |

And extend the "fixed endpoint" section (wherever it lives in the unchanged 209-278 range) with a fourth bullet mirroring zh-cn lines 189-190.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@docs-site/src/content/docs/ru/reference/configuration.md` at line 166, Update
the Russian configuration documentation to match the English and zh-cn
descriptions of collision-protected fixed API-key presets: clarify in the
baseUrl documentation that an existing same-named custom provider preserves its
baseUrl and adapter, then add the corresponding fourth bullet to the fixed
provider endpoints section. Keep the wording consistent with the existing
Russian terminology and zh-cn guidance.

Source: Path instructions

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@docs-site/src/content/docs/guides/providers.md`:
- Around line 222-226: Remove the blank line inside the synchronized Baseten
blockquotes at docs-site/src/content/docs/guides/providers.md lines 222-226,
docs-site/src/content/docs/ja/guides/providers.md lines 156-160, and
docs-site/src/content/docs/ko/guides/providers.md lines 156-160, keeping each
blockquote contiguous.

In `@docs-site/src/content/docs/ru/getting-started/quickstart.md`:
- Around line 16-17: Update the provider-selection sentence to use the correct
Russian numeral agreement, changing “один из 61 встроенного пресета” to “один из
61 встроенных пресетов” while preserving the rest of the quickstart content.

In `@src/providers/model-discovery.ts`:
- Around line 273-280: Add documentation to the predicate union declaration in
the registry module describing the `containsAny` and `containsAll` semantics:
string upstream values use substring matching, while array values use exact
element matching. Keep the existing comparison behavior in the `containsAny` and
`containsAll` branches of model discovery unchanged; only make this contract
clear for registry authors.

---

Outside diff comments:
In `@docs-site/src/content/docs/ru/reference/configuration.md`:
- Line 166: Update the Russian configuration documentation to match the English
and zh-cn descriptions of collision-protected fixed API-key presets: clarify in
the baseUrl documentation that an existing same-named custom provider preserves
its baseUrl and adapter, then add the corresponding fourth bullet to the fixed
provider endpoints section. Keep the wording consistent with the existing
Russian terminology and zh-cn guidance.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 6f2e0626-310e-41e7-b32d-b92ab1438d20

📥 Commits

Reviewing files that changed from the base of the PR and between ca7b104 and 9cdb84c.

📒 Files selected for processing (35)
  • docs-site/src/content/docs/getting-started/quickstart.md
  • docs-site/src/content/docs/guides/providers.md
  • docs-site/src/content/docs/ja/getting-started/quickstart.md
  • docs-site/src/content/docs/ja/guides/providers.md
  • docs-site/src/content/docs/ja/reference/configuration.md
  • docs-site/src/content/docs/ko/getting-started/quickstart.md
  • docs-site/src/content/docs/ko/guides/providers.md
  • docs-site/src/content/docs/ko/reference/configuration.md
  • docs-site/src/content/docs/reference/configuration.md
  • docs-site/src/content/docs/ru/getting-started/quickstart.md
  • docs-site/src/content/docs/ru/guides/providers.md
  • docs-site/src/content/docs/ru/reference/configuration.md
  • docs-site/src/content/docs/zh-cn/getting-started/quickstart.md
  • docs-site/src/content/docs/zh-cn/guides/providers.md
  • docs-site/src/content/docs/zh-cn/reference/configuration.md
  • src/codex/catalog/parsing.ts
  • src/codex/catalog/provider-fetch.ts
  • src/oauth/index.ts
  • src/oauth/key-providers.ts
  • src/oauth/login-cli.ts
  • src/providers/derive.ts
  • src/providers/model-discovery.ts
  • src/providers/registry.ts
  • src/router.ts
  • src/server/auth-cors.ts
  • src/server/management/provider-routes.ts
  • src/server/management/shared.ts
  • structure/01_runtime.md
  • tests/baseten-provider.test.ts
  • tests/codex-catalog.test.ts
  • tests/fixtures/baseten-models.json
  • tests/fixtures/provider-model-discovery.json
  • tests/provider-model-discovery-contract.test.ts
  • tests/provider-registry-parity.test.ts
  • tests/umans-provider.test.ts

Comment thread docs-site/src/content/docs/guides/providers.md
Comment thread docs-site/src/content/docs/ru/getting-started/quickstart.md Outdated
Comment thread src/providers/model-discovery.ts
@olddonkey
olddonkey force-pushed the codex/572-baseten-model-apis branch 2 times, most recently from 7faf2e4 to 124f427 Compare July 29, 2026 05:02

Copy link
Copy Markdown
Contributor Author

Review follow-up for the outside-diff Russian collision-preservation finding: that review was anchored to the old 9cdb84c3 head. The current stacked head includes 4e8e7d5 from #652, which already updates the Russian baseUrl row, adds the fixed-provider-endpoints section, and documents the same-named custom-provider preservation case. No additional code or documentation change is needed for that item.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/codex/catalog/provider-fetch.ts (1)

219-239: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Prioritize canonical capability flags before truncation.

If capabilities/features already contributes 32 values, the later supports_tools and supports_reasoning additions are removed by slice(0, 32). A valid upstream boolean can therefore be omitted from the catalog. Add canonical flags before untrusted labels, or cap generic additions while reserving capacity.

Proposed fix
 function modelCapabilities(item: ProviderModelsApiItem): string[] | undefined {
   const metadata = plainRecord(item.metadata);
   const metadataCapabilities = metadata?.capabilities;
   const capabilityRecord = plainRecord(metadataCapabilities) ?? plainRecord(item.capabilities);
   const out = new Set<string>();
+  for (const field of ["supports_tools", "supports_tool_calling", "supports_function_calling"] as const) {
+    if (item[field] === true) out.add("tools");
+  }
+  for (const field of ["supports_reasoning", "reasoning"] as const) {
+    if (item[field] === true) out.add("reasoning");
+  }
   for (const list of [item.capabilities, item.features, item.supported_features, metadataCapabilities]) {
-    for (const capability of normalizedStringList(list) ?? []) out.add(capability);
+    for (const capability of normalizedStringList(list) ?? []) {
+      if (out.size >= 32) break;
+      out.add(capability);
+    }
   }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/codex/catalog/provider-fetch.ts` around lines 219 - 239, Update the
capability aggregation flow so canonical boolean-derived values from
supports_tools/supports_tool_calling/supports_function_calling and
supports_reasoning/reasoning are added before generic capabilities and metadata
labels. Preserve the 32-value limit while ensuring these canonical “tools” and
“reasoning” values are retained when present, then add untrusted labels only
with remaining capacity.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@docs-site/src/content/docs/ja/guides/providers.md`:
- Around line 156-160: Remove the blank separator between the consecutive
Baseten and Tencent blockquotes in
docs-site/src/content/docs/ja/guides/providers.md lines 156-160 and
docs-site/src/content/docs/ko/guides/providers.md lines 156-160, keeping the
blockquote lines contiguous to satisfy markdownlint MD028.

---

Outside diff comments:
In `@src/codex/catalog/provider-fetch.ts`:
- Around line 219-239: Update the capability aggregation flow so canonical
boolean-derived values from
supports_tools/supports_tool_calling/supports_function_calling and
supports_reasoning/reasoning are added before generic capabilities and metadata
labels. Preserve the 32-value limit while ensuring these canonical “tools” and
“reasoning” values are retained when present, then add untrusted labels only
with remaining capacity.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: a890a1e3-1a47-4f3d-a121-0a23983f7ff4

📥 Commits

Reviewing files that changed from the base of the PR and between 9cdb84c and 124f427.

📒 Files selected for processing (24)
  • docs-site/src/content/docs/getting-started/quickstart.md
  • docs-site/src/content/docs/guides/providers.md
  • docs-site/src/content/docs/ja/getting-started/quickstart.md
  • docs-site/src/content/docs/ja/guides/providers.md
  • docs-site/src/content/docs/ja/reference/configuration.md
  • docs-site/src/content/docs/ko/getting-started/quickstart.md
  • docs-site/src/content/docs/ko/guides/providers.md
  • docs-site/src/content/docs/ko/reference/configuration.md
  • docs-site/src/content/docs/reference/configuration.md
  • docs-site/src/content/docs/ru/getting-started/quickstart.md
  • docs-site/src/content/docs/ru/guides/providers.md
  • docs-site/src/content/docs/ru/reference/configuration.md
  • docs-site/src/content/docs/zh-cn/getting-started/quickstart.md
  • docs-site/src/content/docs/zh-cn/guides/providers.md
  • src/codex/catalog/provider-fetch.ts
  • src/oauth/index.ts
  • src/providers/registry.ts
  • src/server/management/provider-routes.ts
  • structure/01_runtime.md
  • tests/baseten-provider.test.ts
  • tests/fixtures/baseten-models.json
  • tests/provider-connection-test.test.ts
  • tests/provider-model-discovery-contract.test.ts
  • tests/provider-registry-parity.test.ts

@olddonkey
olddonkey force-pushed the codex/572-baseten-model-apis branch from 124f427 to f345775 Compare July 29, 2026 07:47

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 5

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@docs-site/src/content/docs/ja/guides/providers.md`:
- Around line 156-160: Remove the blank separator between consecutive blockquote
paragraphs in docs-site/src/content/docs/ja/guides/providers.md lines 156-160,
docs-site/src/content/docs/ko/guides/providers.md lines 156-160, and
docs-site/src/content/docs/ru/guides/providers.md lines 167-171, preserving the
separate blockquote paragraphs.

In `@structure/01_runtime.md`:
- Around line 80-81: Update the discovery-limit guidance in
structure/01_runtime.md lines 80-81,
docs-site/src/content/docs/ru/reference/configuration.md lines 330-334, and
docs-site/src/content/docs/zh-cn/reference/configuration.md lines 287-290 to
state the generic 4 MiB response and 2,000 raw-row defaults, plus the Baseten
preset overrides of 1 MiB and 256 models at every site. Keep all translated
pages synchronized with the runtime behavior.

In `@tests/baseten-provider.test.ts`:
- Around line 273-280: Update the adapter-mismatch test around routeModel and
basetenConfig so it supplies a non-canonical custom baseUrl while retaining
adapter: "anthropic". Assert that customAdapter preserves this destination,
ensuring registry retargeting cannot pass the test by leaving the canonical URL
unchanged; keep the existing provider and authMode assertions.
- Around line 217-225: Update the registry assertion’s reasoning configuration
in the toMatchObject block around noReasoningModels or the model-specific
reasoning map to explicitly include moonshotai/Kimi-K2.6. Ensure the existing
Kimi request assertion in the Kimi route test is backed by that registry entry
and continues suppressing reasoning_effort.

In `@tests/provider-model-discovery-contract.test.ts`:
- Around line 34-69: Ensure discovery-cache cleanup is uniform across temporary
registry mutations. In tests/provider-model-discovery-contract.test.ts lines
34-69, update withRegistryDiscovery to call clearModelCache(providerId) in
finally and export the shared helper as needed; in
tests/provider-connection-test.test.ts lines 153-182, replace the inline
together discovery mutate/restore logic with that helper so the temporary state
is restored and cached rows are cleared before subsequent probes.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: a4308713-4f36-49b7-adae-bd345c8a28b0

📥 Commits

Reviewing files that changed from the base of the PR and between 124f427 and f345775.

📒 Files selected for processing (36)
  • docs-site/src/content/docs/getting-started/quickstart.md
  • docs-site/src/content/docs/guides/providers.md
  • docs-site/src/content/docs/ja/getting-started/quickstart.md
  • docs-site/src/content/docs/ja/guides/providers.md
  • docs-site/src/content/docs/ja/reference/configuration.md
  • docs-site/src/content/docs/ko/getting-started/quickstart.md
  • docs-site/src/content/docs/ko/guides/providers.md
  • docs-site/src/content/docs/ko/reference/configuration.md
  • docs-site/src/content/docs/reference/configuration.md
  • docs-site/src/content/docs/ru/getting-started/quickstart.md
  • docs-site/src/content/docs/ru/guides/providers.md
  • docs-site/src/content/docs/ru/reference/configuration.md
  • docs-site/src/content/docs/zh-cn/getting-started/quickstart.md
  • docs-site/src/content/docs/zh-cn/guides/providers.md
  • docs-site/src/content/docs/zh-cn/reference/configuration.md
  • src/codex/catalog/parsing.ts
  • src/codex/catalog/provider-fetch.ts
  • src/oauth/index.ts
  • src/oauth/key-providers.ts
  • src/oauth/login-cli.ts
  • src/providers/derive.ts
  • src/providers/model-discovery.ts
  • src/providers/registry.ts
  • src/router.ts
  • src/server/auth-cors.ts
  • src/server/management/provider-routes.ts
  • src/server/management/shared.ts
  • structure/01_runtime.md
  • tests/baseten-provider.test.ts
  • tests/codex-catalog.test.ts
  • tests/fixtures/baseten-models.json
  • tests/fixtures/provider-model-discovery.json
  • tests/provider-connection-test.test.ts
  • tests/provider-model-discovery-contract.test.ts
  • tests/provider-registry-parity.test.ts
  • tests/umans-provider.test.ts

Comment thread docs-site/src/content/docs/ja/guides/providers.md
Comment thread structure/01_runtime.md
Comment thread tests/baseten-provider.test.ts
Comment thread tests/baseten-provider.test.ts
Comment thread tests/provider-model-discovery-contract.test.ts
@Wibias Wibias linked an issue Jul 29, 2026 that may be closed by this pull request
3 tasks
@olddonkey
olddonkey force-pushed the codex/572-baseten-model-apis branch from f345775 to 879efb2 Compare July 29, 2026 17:43

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/server/auth-cors.ts (1)

179-182: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Use the shared admin-token resolver.

Line 179 accepts only the environment token, while src/oauth/login-cli.ts Line 13 sends the file-backed fallback from configuredAdminToken(). With no OPENCODEX_ADMIN_AUTH_TOKEN but a configured token file, proxy-update requests send a token the server rejects. Delegate this helper to configuredAdminToken() and add a file-only-token regression test.

Proposed fix
+import { configuredAdminToken } from "../lib/admin-secrets";
+
 export function configuredAdminAuthToken(): string | undefined {
-  const token = process.env.OPENCODEX_ADMIN_AUTH_TOKEN?.trim();
-  return token || undefined;
+  return configuredAdminToken() ?? undefined;
 }

As per path instructions, “A behavior change in src/ should come with a focused regression test near the existing tests for that subsystem.”

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/server/auth-cors.ts` around lines 179 - 182, Update
configuredAdminAuthToken() to delegate to the shared configuredAdminToken()
resolver so environment and file-backed tokens use identical precedence. Add a
focused regression test near the existing auth/CORS tests covering a configured
token file when OPENCODEX_ADMIN_AUTH_TOKEN is absent, and assert that the file
token is returned.

Source: Path instructions

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@docs-site/src/content/docs/zh-cn/guides/providers.md`:
- Around line 147-151: Update the Baseten Truss sentence in the Chinese provider
documentation to describe dedicated predict endpoints as using different hosts
and request schemas/formats, not different protocols. Preserve the surrounding
wording and keep the blank separator before the Tencent callout unchanged.

In `@src/providers/model-discovery.ts`:
- Around line 87-93: Update the path validation in the spec.path guard to reject
any path segment equal to "..", including repeated or embedded traversal
segments such as "../../internal/models". Preserve acceptance of ordinary
relative paths like "models" and the existing scheme, protocol-relative, query,
fragment, and length checks.

---

Outside diff comments:
In `@src/server/auth-cors.ts`:
- Around line 179-182: Update configuredAdminAuthToken() to delegate to the
shared configuredAdminToken() resolver so environment and file-backed tokens use
identical precedence. Add a focused regression test near the existing auth/CORS
tests covering a configured token file when OPENCODEX_ADMIN_AUTH_TOKEN is
absent, and assert that the file token is returned.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: bb92fa4f-53dd-4d98-9d51-77b07ecba819

📥 Commits

Reviewing files that changed from the base of the PR and between f345775 and 879efb2.

📒 Files selected for processing (36)
  • docs-site/src/content/docs/getting-started/quickstart.md
  • docs-site/src/content/docs/guides/providers.md
  • docs-site/src/content/docs/ja/getting-started/quickstart.md
  • docs-site/src/content/docs/ja/guides/providers.md
  • docs-site/src/content/docs/ja/reference/configuration.md
  • docs-site/src/content/docs/ko/getting-started/quickstart.md
  • docs-site/src/content/docs/ko/guides/providers.md
  • docs-site/src/content/docs/ko/reference/configuration.md
  • docs-site/src/content/docs/reference/configuration.md
  • docs-site/src/content/docs/ru/getting-started/quickstart.md
  • docs-site/src/content/docs/ru/guides/providers.md
  • docs-site/src/content/docs/ru/reference/configuration.md
  • docs-site/src/content/docs/zh-cn/getting-started/quickstart.md
  • docs-site/src/content/docs/zh-cn/guides/providers.md
  • docs-site/src/content/docs/zh-cn/reference/configuration.md
  • src/codex/catalog/parsing.ts
  • src/codex/catalog/provider-fetch.ts
  • src/oauth/index.ts
  • src/oauth/key-providers.ts
  • src/oauth/login-cli.ts
  • src/providers/derive.ts
  • src/providers/model-discovery.ts
  • src/providers/registry.ts
  • src/router.ts
  • src/server/auth-cors.ts
  • src/server/management/provider-routes.ts
  • src/server/management/shared.ts
  • structure/01_runtime.md
  • tests/baseten-provider.test.ts
  • tests/codex-catalog.test.ts
  • tests/fixtures/baseten-models.json
  • tests/fixtures/provider-model-discovery.json
  • tests/provider-connection-test.test.ts
  • tests/provider-model-discovery-contract.test.ts
  • tests/provider-registry-parity.test.ts
  • tests/umans-provider.test.ts

Comment thread docs-site/src/content/docs/zh-cn/guides/providers.md
Comment thread src/providers/model-discovery.ts
@lidge-jun

Copy link
Copy Markdown
Owner

Status after the prerequisite landed: #652 is merged (48f2e8362), so the discovery contract no longer blocks this PR.

I reran the failing Windows job and looked at what it actually reported. The rerun came back cancelled at 12m05s, not failed:

job 90733427766   conclusion: cancelled
started 23:11:50Z   completed 23:23:55Z   (12m05s)
Test: cancelled     later steps: skipped

That is the test job hitting timeout-minutes: 12, which gh pr checks renders as fail. It is not this preset failing. I filed #717 with the run-by-run evidence — the last green Windows run took 11 minutes against the 12-minute ceiling, and every dev run after it was cancelled too, so this is repository-wide rather than specific to #653.

Your code checks out locally on my side:

bun test tests/baseten*.test.ts tests/provider-registry-parity.test.ts tests/model-discovery-contract.test.ts
  38 pass / 0 fail
bun x tsc --noEmit   clean

So this is waiting on CI capacity, not on a change from you. Two things worth doing when you get a chance:

  1. Rebase onto current dev. feat(providers): add bounded model discovery contract #652 has landed, and rebasing lets the discovery contract you build on be the merged version rather than the PR-branch version. Worth re-checking whether any modelDiscovery declaration here should now use a lower per-provider limit from the merged contract instead of a local constant.
  2. Nothing else — once CI: windows-latest test job cancelled at the 12-minute ceiling, reported as a failing check #717 is sorted and CI can finish, this should go green as-is.

One note for the remaining batches in #572: the first failure on this PR was a genuine Test failure before the rerun, so please do not read this comment as "Windows failures are always timeouts." The distinction is in gh api repos/lidge-jun/opencodex/commits/<sha>/check-runsconclusion: failure means look at the logs, conclusion: cancelled means the job ran out of time.

lidge-jun added a commit that referenced this pull request Jul 30, 2026
The `test` job ran with `timeout-minutes: 12` while a green Windows run
takes 11.8 minutes, leaving about 12 seconds of margin. Runner variance,
not the code under review, decided the outcome: PR #711's rerun finished
at 11.8min and passed, PR #653's was killed at 12.0min with `Test`
cancelled and every later step skipped.

That flakiness is expensive to review around, because `gh pr checks`
renders a cancelled job as `fail`. A red Windows check could mean a real
failure, a `cancel-in-progress` concurrency cancel, or this timeout, and
telling them apart requires reading `conclusion` from the check-runs API
plus per-job timings.

Measured on run 30459554635 (same suite, same commit):

  ubuntu-latest    4.6 min
  macos-latest     5.6 min
  windows-latest  11.8 min

20 minutes keeps a green Windows run green with margin. It does not
address why Windows needs ~2.5x Linux on an identical suite; the comment
says so explicitly, because the ceiling has already been raised once
(8 -> 12) for this same reason and chasing it again is not a fix. The
`npm-global-smoke` job is untouched at 8 minutes: it completes in 1-2
minutes and was never near its limit.

Refs #717
@olddonkey
olddonkey force-pushed the codex/572-baseten-model-apis branch 2 times, most recently from fe283d6 to 7e0f779 Compare July 30, 2026 07:18

Copy link
Copy Markdown
Contributor Author

Review follow-up is complete for the current head (7e0f7793):

  • Baseten-scoped fixes are on this PR, including exact Kimi reasoning allowlist assertions, a non-tautological custom-destination test, zh-CN wording, and documented 1 MiB / 256-row discovery limits across maintained locales.
  • Shared contract hardening was intentionally split into fix(providers): harden discovery contract cleanup #743 now that feat(providers): add bounded model discovery contract #652 is merged. It covers .. path-segment rejection plus deterministic registry/cache cleanup in tests.
  • I did not apply the out-of-diff auth-cors.ts suggestion because its reported failure mode does not exist: file-backed admin tokens are loaded into management auth state and accepted by requireManagementAuth, while their required ocx_admin_... format is already blocked from provider forwarding by the proxy-admission secret prefix guard.

Local verification for this PR: typecheck, privacy scan, focused tests, docs build, and the full suite all pass (6036 pass / 2 skip / 0 fail).

Copy link
Copy Markdown
Contributor Author

CI note: the only remaining red check is the Windows matrix job. Its single failure is unrelated to this PR's diff: storage-mutation-race.test.ts completed the test body, then Windows failed to remove its temporary directory with EBUSY: resource busy or locked during teardown. The same job passed 6033 tests, and Ubuntu/macOS plus both npm-global Windows checks are green.

I attempted both the single-job and failed-jobs rerun APIs, but GitHub requires upstream repository admin rights for this run. A maintainer will need to re-run the failed Windows job: https://github.com/lidge-jun/opencodex/actions/runs/30522540376/job/90805964297

@lidge-jun

Copy link
Copy Markdown
Owner

NEEDS-CHANGES — evidence only. The code is the strongest of the current preset submissions.

I read the diff rather than the thread first, and there is nothing to argue with technically. https://inference.baseten.co/v1, liveModels: true with sane 1 MiB / 256-row discovery bounds, preserveCustomDestination: true, and no hardcoded selectable catalog — only capability metadata for specific live slugs at registry.ts:412-447, which is the right place to draw that line. tests/baseten-provider.test.ts binds the derived login/init/dashboard contracts, authenticated discovery, the real chat endpoint and Bearer header, reasoning allowlists and their omission for unsupported models, slash-ID routing in both forms, and non-canonical base URL preservation.

I also read the 24 existing reviews so I would not add a 25th copy of something already settled. Those rounds covered the Russian collision documentation, MD028 formatting, numeral agreement, containsAny/containsAll semantics, capability priority before discovery truncation, Kimi reasoning allowlists, the previously tautological custom-destination test, the 1 MiB/256-row documentation across locales, the zh-CN schema/protocol wording, and the discovery-cache and .. handling that moved to #743. As far as I can tell those are resolved or withdrawn.

What is left is a gate that applies to every preset regardless of code quality. MAINTAINERS.md:33-42 treats a canonical preset as a credential-destination change and requires, before merge:

  • documented OpenAI-compatible endpoints, including authenticated GET /v1/models since this entry declares liveModels — the diff links the Model APIs overview, API key, reasoning and vision pages, but not a clear primary-source citation of the exact chat endpoint and /v1/models contract
  • terms of service and the operating legal entity — missing
  • resale or routing authorization — not applicable; Baseten's own material describes them operating deployment and inference APIs, so I am reading them as a first-party host, not a reseller
  • a named maintenance owner — missing, and this one matters more than it looks. When an endpoint changes shape a year from now, someone has to notice
  • a citable verification date — missing

The PR body requests security review, which is right, but none of the 24 reviews is an approval or an explicit maintainer security sign-off, so that requirement is still open.

What happens next: add the ToS and operating entity, a dated primary-source citation for the chat endpoint and authenticated /v1/models, and name a maintenance owner. Then request explicit security review. This merges cleanly against current dev and dev CI is fully green now.

Thanks for the patience through 24 rounds — the code got better for it.

@lidge-jun lidge-jun left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Formalizing the disposition so it shows on your dashboard.

To be clear about what this is not: the code is the strongest of the current preset submissions and I am not asking you to change it. This is the MAINTAINERS.md:33-42 evidence gate only.

Missing: terms of service and operating legal entity, a dated primary-source citation for the exact chat endpoint and authenticated GET /v1/models, and a named maintenance owner. Resale authorization does not apply — Baseten reads as a first-party inference host.

None of the 24 existing reviews is a security sign-off, so that requirement is also still open.

Full reasoning in my earlier comment.

lidge-jun added a commit that referenced this pull request Jul 31, 2026
A signup-credit row in the free directory, not a canonical registry
preset. That distinction is the point: MAINTAINERS.md sets a
credential-destination evidence bar for `PROVIDER_REGISTRY` entries, and
an inert directory reference is the documented placement when that
evidence is not fully assembled.

The submission carries a dated end-to-end check (2026-07-30): the
OpenAI-shaped `/v1/models` catalog and a real chat completion, both
recorded inline next to the entry.

Contributed by a Baseten employee; disclosed, which under MAINTAINERS.md
is neither disqualifying nor a reason to lower the bar. Promotion to a
canonical preset would still need ToS, operating legal entity, and a
named maintenance owner -- see #653 for that path.

Co-authored-by: bitkyc08-arch <bitkyc08@gmail.com>
@olddonkey
olddonkey force-pushed the codex/572-baseten-model-apis branch from 7e0f779 to ea129f5 Compare August 1, 2026 00:43
@olddonkey

Copy link
Copy Markdown
Contributor Author

Addressed the evidence-only changes requested and restacked the single Baseten commit onto current dev (6d54e5f3).

  • The PR description now cites Baseten primary sources for the exact Chat Completions endpoint and Bearer-authenticated GET /v1/models, records the 2026-07-31 verification date, identifies Baseten Labs, Inc. and its Terms, explains why resale authorization is not applicable, names @olddonkey as maintenance owner, and discloses no affiliation or compensation.
  • The obsolete feat(providers): add bounded model discovery contract #652 stack/dependency wording is removed; [Provider] Promote a verified batch of OpenAI-compatible inference providers #572 is linked without a closing keyword.
  • Final local verification: focused provider/contract tests 186/0, full suite 6,494 pass / 4 skip / 0 fail, typecheck and privacy scan clean, docs build 146 pages.
  • The current head is ea129f5f; GitHub now reports the PR mergeable.

@Ingwannu, this is an explicit request for the maintainer security review/sign-off required for this credential-destination change. @lidge-jun, the evidence gate from your requested-changes review is now addressed; please re-review when CI completes.

@olddonkey

Copy link
Copy Markdown
Contributor Author

CI follow-up for head ea129f5f: the Windows matrix job is red because Bun 1.3.14 crashed with an internal assertion failure, not because a Baseten assertion failed. The log shows the suite reached storage-mutation-race.test.ts, passed the first two cases, then Bun emitted panic ... Internal assertion failure / This indicates a bug in Bun, not your code after 661s. Ubuntu and macOS main jobs, all npm-global jobs, and the local 6,494-test suite are green.

Failed job: https://github.com/lidge-jun/opencodex/actions/runs/30676226719/job/91303936452

I am not changing the provider diff for this runner crash. A maintainer can rerun the job if a green Windows check is required.

@Ingwannu Ingwannu left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed current head ea129f5. The preset is limited to Baseten shared Model APIs, uses the documented fixed inference host and Bearer-authenticated model catalog, denies redirects through the shared fetch path, bounds discovery, preserves same-named custom destinations, and does not log or persist registry-only trust metadata. The PR now includes dated primary-source endpoint evidence, Baseten Labs, Inc. terms/entity, first-party-host rationale, affiliation disclosure, and @olddonkey as maintenance owner. Focused provider/registry/discovery tests (38) and typecheck pass locally. Maintainer credential-destination sign-off: approved. I am leaving the previous owner CHANGES_REQUESTED review intact for lidge-jun to re-review/dismiss rather than overriding it.

lidge-jun added a commit that referenced this pull request Aug 1, 2026
The windows leg dominates this matrix at 11.8min against ubuntu's 4.6min,
and #711/#653 were decided by runner variance rather than by the code under
review. A maintainer's own Windows box removes that, but it is a personal
machine on a home network: whatever runs on it runs as a local user with
that user's files and LAN in reach.

So the routing decision is made from the event, not from the workflow body.
`push` on dev/main/preview requires the push permission, which only the
MAINTAINERS.md set holds, and `workflow_dispatch` requires write access.
Those two go to the home box. `pull_request` never does.

An author check inside this file would not be equivalent. `ci.yml` runs from
the PR head on `pull_request`, so any `if: author_association == ...` guard
is deletable by the same patch it is meant to stop, as are the tsconfig,
lockfile and postinstall hooks the run would otherwise honour. Only a
decision made before a runner is chosen survives a hostile head.

Two supporting details. `matrix.include` carries a fixed `name` because a
label-array runner renders into the check name, so deriving it would rename
the required check depending on which machine served it. And the self-hosted
leg wipes its workspace first: a persistent working directory keeps files
that the commit under test deleted, which passes a suite against a tree that
no longer exists in git.

Routing is gated on the `OCX_SELF_HOSTED_WINDOWS` repository variable, which
is unset today, so every leg still resolves to windows-latest until the
runner is registered and the variable is flipped.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Provider] Promote a verified batch of OpenAI-compatible inference providers

3 participants